package com.seuic.hnapps.project;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.widget.CardView;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.orhanobut.logger.Logger;
import com.seuic.hnapps.BaseActivity;
import com.seuic.hnapps.R;
import com.seuic.hnapps.bean.CardBinInfo_bean;
import com.seuic.hnapps.bean.StatisticalData_bean;
import com.seuic.hnapps.bean.Summary_Bean;
import com.seuic.hnapps.constants.EmvConstants;
import com.seuic.hnapps.posdsdk.pos_func.PosCallbacks;
import com.seuic.hnapps.posdsdk.pos_func.PosFuncs;
import com.seuic.hnapps.util.CommAdapter;
import com.seuic.hnapps.util.Constants;
import com.seuic.hnapps.util.PinPad;
import com.seuic.hnapps.util.PzGetUtils;
import com.seuic.hnapps.util.ServiceCommon;
import com.seuic.hnapps.util.SpUtils;
import com.seuic.hnapps.util.Utils;
import com.seuic.hnapps.util.VTAInterface;
import com.seuic.hnapps.util.ZHCCInterface;
import com.seuic.hnapps.util.ZHCJInterface;
import com.seuic.hnapps.util.ZHCQInterface;
import com.solab.enc.DES3;
import com.solab.enc.HexT;
import com.solab.enc.SMS4;
import com.solab.iso8583.IsoMessage;
import com.solab.iso8583.MessageFactory;

import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 智慧存
 * 2019年7月30日11:39:25
 * isjingkai
 */
public class Wisdomtosave_Activity extends BaseActivity {

    @BindView(R.id.base_back_btn)
    LinearLayout baseBackBtn;
    @BindView(R.id.base_title_text)
    TextView baseTitleText;
    @BindView(R.id.wisdomtosave_homelayout)
    LinearLayout wisdomtosave_homelayout;
    //    @BindView(R.id.please_input_iccard_okbtn)
//    Button pleaseInputIccardOkbtn;
    @BindView(R.id.please_input_iccard_layout)
    LinearLayout pleaseInputIccardLayout;
    @BindView(R.id.ficationing_layout)
    LinearLayout ficationingLayout;
    @BindView(R.id.contract_information_time)
    TextView contractInformationTime;
    @BindView(R.id.topup_success_num)
    TextView topupSuccessNum;
    @BindView(R.id.contract_information_floor)
    TextView contractInformationFloor;
    @BindView(R.id.contract_information_basenum)
    TextView contractInformationBasenum;
    @BindView(R.id.contract_information_name)
    TextView contractInformationName;
    //    @BindView(R.id.contract_information_balance)
//    TextView contractInformationBalance;
    @BindView(R.id.contract_information_okbtn)
    Button contractInformationOkbtn;
    @BindView(R.id.contract_information_layout)
    CardView contractInformationLayout;

    Runnable runnable;
    Handler handler;
    @BindView(R.id.wisdomtosave_signup_btn)
    Button wisdomtosaveSignupBtn;
    @BindView(R.id.wisdomtosave_unbind_btn)
    Button wisdomtosaveUnbindBtn;
    @BindView(R.id.wisdomtosave_look_btn)
    Button wisdomtosaveLookBtn;
    @BindView(R.id.dealing_layout)
    LinearLayout dealingLayout;
    @BindView(R.id.wisdomtosave_cardview)
    CardView wisdomtosaveCardview;
    @BindView(R.id.product_presentaion_noBtn)
    Button productPresentaionNoBtn;
    @BindView(R.id.product_presentaion_okBtn)
    Button productPresentaionOkBtn;
    @BindView(R.id.product_presentaion_layout)
    CardView productPresentaionLayout;
    @BindView(R.id.select_contract_type_hly)
    Button selectContractTypeHly;
    @BindView(R.id.select_contract_type_cxy)
    Button selectContractTypeCxy;
    @BindView(R.id.select_contract_type_layout)
    LinearLayout selectContractTypeLayout;
    @BindView(R.id.signacontract_success_time)
    TextView signacontractSuccessTime;
    @BindView(R.id.signacontract_success_money)
    TextView signacontractSuccessMoney;
    @BindView(R.id.signacontract_success_balancefloor)
    TextView signacontractSuccessBalancefloor;
    @BindView(R.id.signacontract_success_cardinal)
    TextView signacontractSuccessCardinal;
    @BindView(R.id.signacontract_success_name)
    TextView signacontractSuccessName;
    @BindView(R.id.signacontract_success_balance)
    TextView signacontractSuccessBalance;
    @BindView(R.id.signacontract_success_okbtn)
    Button signacontractSuccessOkbtn;
    @BindView(R.id.signacontract_success_layout)
    CardView signacontractSuccessLayout;
    @BindView(R.id.unbind_appoint_num)
    TextView unbindAppointNum;
    @BindView(R.id.unbind_appoint_interest)
    TextView unbindAppointInterest;
    @BindView(R.id.unbind_appoint_interesttax)
    TextView unbindAppointInteresttax;
    @BindView(R.id.unbind_appoint_money)
    TextView unbindAppointMoney;
    @BindView(R.id.unbind_appoint_btn)
    Button unbindAppointBtn;
    @BindView(R.id.unbind_appoint_layout)
    LinearLayout unbindAppointLayout;
    @BindView(R.id.sure_printingpeper_okbtn)
    Button surePrintingpeperOkbtn;
    @BindView(R.id.sure_printingpeper_layout)
    LinearLayout surePrintingpeperLayout;
    @BindView(R.id.printing_layout)
    LinearLayout printingLayout;
    private PosFuncs posFuncs;
    private String bindNum;
    private String pass_word;
    private String field55;
    private int num;
    private String make_type;
    private String CardType;
    private String track2Data;
    private String s_number;
    private String track3Data;
    private String time;
    private String rwNUm;
    private String pz_nums;
    private String zdzcjss;
    private String hqyexxs;
    private String username;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wisdomtosave_);
        ButterKnife.bind(this);
        this.setBackBtClick(R.id.base_back_btn);
        this.setTitleText(R.id.base_title_text, "(   " + "智慧存" + "   )");
        handler = new Handler();
        posFuncs = PosFuncs.getInstace();
        posFuncs.init(this);
    }

    @OnClick({
//            R.id.please_input_iccard_okbtn,
            R.id.contract_information_okbtn,
            R.id.wisdomtosave_signup_btn, R.id.wisdomtosave_unbind_btn,
            R.id.wisdomtosave_look_btn, R.id.product_presentaion_noBtn,
            R.id.product_presentaion_okBtn, R.id.select_contract_type_hly,
            R.id.select_contract_type_cxy, R.id.signacontract_success_okbtn,
            R.id.unbind_appoint_btn, R.id.sure_printingpeper_okbtn})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.wisdomtosave_signup_btn:
                //签约
                wisdomtosaveCardview.setVisibility(View.GONE);
                wisdomtosave_homelayout.setVisibility(View.GONE);
                productPresentaionLayout.setVisibility(View.VISIBLE);
                break;
            case R.id.wisdomtosave_unbind_btn:
                //解约
                wisdomtosave_homelayout.setVisibility(View.GONE);
//                unbindAppointLayout.setVisibility(View.VISIBLE);
                pleaseInputIccardLayout.setVisibility(View.VISIBLE);
                tradeWithCards(0);
                make_type = "zhcjy";
                break;
            case R.id.wisdomtosave_look_btn:
                //查阅
                wisdomtosave_homelayout.setVisibility(View.GONE);
                pleaseInputIccardLayout.setVisibility(View.VISIBLE);

                tradeWithCards(0);
                make_type = "zhccy";
                break;
//            case R.id.please_input_iccard_okbtn:
//                //确认插入卡
//                pleaseInputIccardLayout.setVisibility(View.GONE);
//                ficationingLayout.setVisibility(View.VISIBLE);
//                runnable = new Runnable() {
//                    @Override
//                    public void run() {
//                        ficationingLayout.setVisibility(View.GONE);
//                        dealingLayout.setVisibility(View.VISIBLE);
//                    }
//                };
//                handler.postDelayed(runnable, 300);
//                runnable = new Runnable() {
//                    @Override
//                    public void run() {
//                        wisdomtosaveCardview.setVisibility(View.GONE);
//                        contractInformationLayout.setVisibility(View.VISIBLE);
//                    }
//                };
//                handler.postDelayed(runnable, 2000);
//
//                break;
            case R.id.contract_information_okbtn:
                //确认签约信息
                dealingLayout.setVisibility(View.GONE);
                wisdomtosave_homelayout.setVisibility(View.VISIBLE);
                wisdomtosaveCardview.setVisibility(View.VISIBLE);
                contractInformationLayout.setVisibility(View.GONE);
                break;
            case R.id.product_presentaion_noBtn:
                //产品介绍 取消
                this.finish();

                break;
            case R.id.product_presentaion_okBtn:
                //产品介绍 确定
                productPresentaionLayout.setVisibility(View.GONE);

                wisdomtosaveCardview.setVisibility(View.VISIBLE);

                selectContractTypeLayout.setVisibility(View.VISIBLE);
                break;
            case R.id.select_contract_type_hly:
                //选择签约类型 稳利赢
                selectContractTypeLayout.setVisibility(View.GONE);
                pleaseInputIccardLayout.setVisibility(View.VISIBLE);
                make_type = "wly";
                tradeWithCards(0);
                break;
            case R.id.select_contract_type_cxy:
                //选择签约类型 超享赢
                selectContractTypeLayout.setVisibility(View.GONE);
                pleaseInputIccardLayout.setVisibility(View.VISIBLE);
                make_type = "cxy";
                tradeWithCards(0);
                break;
            case R.id.signacontract_success_okbtn:
                //确认签约信息  确认
                signacontractSuccessLayout.setVisibility(View.GONE);
                surePrintingpeperLayout.setVisibility(View.VISIBLE);
                wisdomtosaveCardview.setVisibility(View.VISIBLE);
//                wisdomtosave_homelayout.setVisibility(View.VISIBLE);
                break;
            case R.id.unbind_appoint_btn:
                //解约成功  确认
                unbindAppointLayout.setVisibility(View.GONE);
                surePrintingpeperLayout.setVisibility(View.VISIBLE);

                break;
            case R.id.sure_printingpeper_okbtn:
                printingLayout.setVisibility(View.VISIBLE);
                surePrintingpeperLayout.setVisibility(View.GONE);
                if (make_type.equals("wly") || make_type.equals("cxy")) {
                    paint();
                } else if (make_type.equals("zhcjy")) {
                    paintzhcjy();
                }
                break;
        }
    }

    /**
     * 打印智慧存签约
     */
    private void paintzhcjy() {
        new Thread() {
            @Override
            public void run() {
                super.run();
                posFuncs.printerClearBuffer();
                posFuncs.printerAppendLargeTextAlignCenter("烟台银行 通用凭证");

                posFuncs.printerAppendTextline("交易时间 :" + time);
                posFuncs.printerAppendTextline("设备号 :" + Constants.YANTAI_TERMNO);
                posFuncs.printerAppendTextline("操作员 :" + SpUtils.getSPUtil(getApplicationContext()).getString("make_user", ""));

                posFuncs.printerAppendTextline("账号 :" + bindNum);
                posFuncs.printerAppendTextline("流水号 :" + rwNUm);

                posFuncs.printerAppendTextline("业务类型 :" + "智慧存解约");


                posFuncs.printerAppendTextline("凭证序号 :" + pz_nums);

                posFuncs.printerAppendTextline("客户签字确认 :");
                posFuncs.printerAppendTextline("--------------------------------------");

                posFuncs.printerAppendLargeTextAlignCenter("烟台银行 通用凭证");

                posFuncs.printerAppendTextline("交易时间 :" + time);
                posFuncs.printerAppendTextline("设备号 :" + Constants.YANTAI_TERMNO);
                posFuncs.printerAppendTextline("操作员 :" + SpUtils.getSPUtil(getApplicationContext()).getString("make_user", ""));

                String bindx = bindNum.substring(6, bindNum.length() - 5);
                String bindxs = "*";
                for (int i = 0; i < bindx.length(); i++) {
                    bindxs = bindxs + "*";
                }
                posFuncs.printerAppendTextline("账号 :" + bindNum.substring(0, 6) + bindxs + bindNum.substring(bindNum.length() - 4, bindNum.length()));

                posFuncs.printerAppendTextline("流水号 :" + rwNUm);

                posFuncs.printerAppendTextline("业务类型 :" + "智慧存解约");


                posFuncs.printerAppendTextline("凭证序号 :" + pz_nums);

                posFuncs.printerAppendTextline("客户签字确认 :");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");


                posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                    @Override
                    public void onSuccess() {
                        Toast.makeText(Wisdomtosave_Activity.this, "打印成功", Toast.LENGTH_SHORT).show();
                        finish();
                    }

                    @Override
                    public void onFailed(String error) {
                        if (error.equals("Lack Paper")) {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    Toast.makeText(Wisdomtosave_Activity.this, "请确认打印纸安装正确", Toast.LENGTH_SHORT).show();
                                    surePrintingpeperLayout.setVisibility(View.VISIBLE);
                                    printingLayout.setVisibility(View.GONE);
                                }
                            });
                        }
                    }
                });
            }
        }.start();
    }

    /**
     * 打印智慧存签约
     */
    private void paint() {
        new Thread() {
            @Override
            public void run() {
                super.run();
                posFuncs.printerClearBuffer();
                posFuncs.printerAppendLargeTextAlignCenter("烟台银行 通用凭证");

                posFuncs.printerAppendTextline("交易时间 :" + time);
                posFuncs.printerAppendTextline("设备号 :" + Constants.YANTAI_TERMNO);
                posFuncs.printerAppendTextline("操作员 :" + SpUtils.getSPUtil(getApplicationContext()).getString("make_user", ""));

                posFuncs.printerAppendTextline("账号 :" + bindNum);
                posFuncs.printerAppendTextline("流水号 :" + rwNUm);
                if (make_type.equals("wly")) {
                    posFuncs.printerAppendTextline("业务类型 :" + "智慧存签约");
                    posFuncs.printerAppendTextline("签约产品名称 :" + "稳利赢");
                    posFuncs.printerAppendTextline("活期余额下限 :" + hqyexxs);
                } else {
                    posFuncs.printerAppendTextline("业务类型 :" + "智慧存签约");
                    posFuncs.printerAppendTextline("签约产品名称 :" + "超享赢");
                    posFuncs.printerAppendTextline("活期余额下限 :" + "0.00");
                }
                posFuncs.printerAppendTextline("自动转存基数 :" + zdzcjss);

                posFuncs.printerAppendTextline("凭证序号 :" + pz_nums);

                posFuncs.printerAppendTextline("客户签字确认 :");
                posFuncs.printerAppendTextline("--------------------------------------");
                posFuncs.printerAppendLargeTextAlignCenter("烟台银行 通用凭证");
                posFuncs.printerAppendTextline("交易时间 :" + time);
                posFuncs.printerAppendTextline("设备号 :" + Constants.YANTAI_TERMNO);
                posFuncs.printerAppendTextline("操作员 :" + SpUtils.getSPUtil(getApplicationContext()).getString("make_user", ""));
                String bindx = bindNum.substring(6, bindNum.length() - 5);
                String bindxs = "*";
                for (int i = 0; i < bindx.length(); i++) {
                    bindxs = bindxs + "*";
                }
                posFuncs.printerAppendTextline("账号 :" + bindNum.substring(0, 6) + bindxs + bindNum.substring(bindNum.length() - 4, bindNum.length()));

                posFuncs.printerAppendTextline("流水号 :" + rwNUm);
                if (make_type.equals("wly")) {
                    posFuncs.printerAppendTextline("业务类型 :" + "智慧存签约");
                    posFuncs.printerAppendTextline("签约产品名称 :" + "稳利赢");
                    posFuncs.printerAppendTextline("活期余额下限 :" + hqyexxs);
                } else {
                    posFuncs.printerAppendTextline("业务类型 :" + "智慧存签约");
                    posFuncs.printerAppendTextline("签约产品名称 :" + "超享赢");
                    posFuncs.printerAppendTextline("活期余额下限 :" + "0.00");
                }

                posFuncs.printerAppendTextline("自动转存基数 :" + zdzcjss);

                posFuncs.printerAppendTextline("凭证序号 :" + pz_nums);

                posFuncs.printerAppendTextline("客户签字确认 :");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");


                posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                    @Override
                    public void onSuccess() {
                        Toast.makeText(Wisdomtosave_Activity.this, "打印成功", Toast.LENGTH_SHORT).show();
                        finish();
                    }

                    @Override
                    public void onFailed(String error) {
                        if (error.equals("Lack Paper")) {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    Toast.makeText(Wisdomtosave_Activity.this, "请确认打印纸安装正确", Toast.LENGTH_SHORT).show();
                                    surePrintingpeperLayout.setVisibility(View.VISIBLE);
                                    printingLayout.setVisibility(View.GONE);
                                }
                            });
                        }
                    }
                });
            }
        }.start();
    }

    private void tradeWithCards(final double money) {
        Logger.e(money + "");
        PinPad.initPinPad(posFuncs);
        new Thread() {
            @Override
            public void run() {

                posFuncs.cardReaderConfig(true, true, true);
                posFuncs.emvTransStart(new PosCallbacks.EmvTransStartCallbacks() {

                    @Override
                    public void onDetectCard(String type) {
                        CardType = type;
                    }

                    @Override
                    public void onConfirmCardInfo(final String pan) {
                        bindNum = pan;
                        posFuncs.emvConfirmCardInfo(EmvConstants.CONFIRM_OK);

                    }

                    @Override
                    public void onOlinePinEntered(String enc, boolean is_no_pin) {
                        if (!is_no_pin) {

                            try {
                                String pin = PinPad.getPin(bindNum, enc);
                                pass_word = pin;
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        } else {
                            Toast.makeText(getApplicationContext(), "请输入密码", Toast.LENGTH_SHORT).show();
                        }
                    }

                    @Override
                    public void onSuccess(Bundle data) {
                        String channel = data.getString(EmvConstants.CHANNEL);
                        if (EmvConstants.CHANNEL_MAGCARD.equals(channel)) {
//                            appendInfo("MagCard Used\n");
//                            appendInfo("Track1: " + data.getString(EmvConstants.TRACK1) + "\n");
//                            appendInfo("Track2: " + data.getString(EmvConstants.TRACK2) + "\n");
//                            appendInfo("Track3: " + data.getString(EmvConstants.TRACK3) + "\n");
                            track3Data = data.getString(EmvConstants.TRACK3);
                            track2Data = data.getString(EmvConstants.TRACK2);
//                            appendInfo("\nFinish\n");
//                            setEmvProcessStatus(false);
                        } else if (EmvConstants.CHANNEL_ICC.equals(channel)) {
//                            appendInfo("ICCard Used\n");
                            track2Data = Utils.formatField57(Utils.getValueFromIccData("57", data.getString(EmvConstants.FEILD_55)));
                            s_number = Utils.getValueFromIccData("5f34", data.getString(EmvConstants.FEILD_55));

                            String ac_type = data.getString(EmvConstants.AC_TYPE);
                            Logger.e("ac_type" + ac_type);
                            Logger.e("Ac Type: " + data.getString(EmvConstants.AC_TYPE) + "\n");
                            Logger.e("Field 55: " + data.getString(EmvConstants.FEILD_55) + "\n");
                            String[] tags =
                                    {
                                            "9F26", "9F27", "9F10", "9F37", "9F36", "95",
                                            "9A", "9C", "9F02", "5F2A", "82", "9F1A", "9F03", "9F33", "9F34", "9F35",
                                            "9F1E", "84", "9F09", "9F41"
                                    };
                            String Field55 = Utils.getField55(tags, data.getString(EmvConstants.FEILD_55));
                            Logger.e("f55" + Field55);
                            if (EmvConstants.AC_TYPE_ARQC.equals(ac_type)) {

                                Bundle bundle = new Bundle();
                                bundle.putString(EmvConstants.RESPONSE_CODE, "3030");
                                posFuncs.emvOnlineResult(new PosCallbacks.EmvOnlineResultCallbacks() {
                                    @Override
                                    public void onSuccess(Bundle data) {
                                        Logger.e("Ac Type: " + data.getString(EmvConstants.AC_TYPE) + "\n");
                                        Logger.e("Field 55: " + data.getString(EmvConstants.FEILD_55) + "\n");

                                    }

                                    @Override
                                    public void onFailed(String error) {

                                    }
                                }, bundle);
                            } else {

                            }
                        } else if (EmvConstants.CHANNEL_ICCL.equals(channel)) {
                            Logger.e("Ac Type: " + data.getString(EmvConstants.AC_TYPE) + "\n");
                            Logger.e("Field 55: " + data.getString(EmvConstants.FEILD_55) + "\n");

                        }
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                pleaseInputIccardLayout.setVisibility(View.GONE);
                                ficationingLayout.setVisibility(View.VISIBLE);
                            }
                        });
                        new Thread(new Runnable() {
                            @Override
                            public void run() {
                                num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
                                Logger.e("第一次获取" + num);
                                excuteVTA(String.valueOf(num), bindNum, CardType, track2Data, s_number);
                                SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
                                Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));
                            }
                        }).start();
                    }

                    @Override
                    public void onFailed(String error) {

                    }
                }, (int) money, 0);
            }
        }.start();
    }

    /**
     * 账户验证
     */
    public void excuteVTA(String transn, String bindNum, String CardTYpe, String track2Data, String s_number) {
        String c_bin_info = SpUtils.getSPUtil(getApplicationContext()).getString("c_bin_info", "null");
        Gson gson = new Gson();
        List<CardBinInfo_bean> beans = gson.fromJson(c_bin_info, new TypeToken<List<CardBinInfo_bean>>() {
        }.getType());
        Logger.e(beans.size() + "beans.size()");
        IsoMessage msg = null;
        VTAInterface inter = new VTAInterface();
        msg = inter.packRequest(bindNum, beans, transn, track2Data, CardTYpe, String.valueOf(2), s_number);
        excuteRequest(msg, "zhrz");
    }

    /**
     * 智慧存解约
     */
    public void excuteZHCJY(String transn) {
        String c_bin_info = SpUtils.getSPUtil(getApplicationContext()).getString("c_bin_info", "null");
        Gson gson = new Gson();
        List<CardBinInfo_bean> beans = gson.fromJson(c_bin_info, new TypeToken<List<CardBinInfo_bean>>() {
        }.getType());
        Logger.e(beans.size() + "beans.size()");
        IsoMessage msg = null;
        ZHCJInterface inter = new ZHCJInterface();
        msg = inter.packRequest(transn, bindNum, "1", CardType, beans, s_number, track2Data, track3Data, field55, pass_word);
        excuteRequest(msg, "zhcjy");
    }

    /**
     * 智慧存查阅
     */
    public void excuteZHCCY(String transn) {
        String c_bin_info = SpUtils.getSPUtil(getApplicationContext()).getString("c_bin_info", "null");
        Gson gson = new Gson();
        List<CardBinInfo_bean> beans = gson.fromJson(c_bin_info, new TypeToken<List<CardBinInfo_bean>>() {
        }.getType());
        Logger.e(beans.size() + "beans.size()");
        IsoMessage msg = null;
        ZHCCInterface inter = new ZHCCInterface();
        msg = inter.packRequest(transn, bindNum, "1", CardType, beans, s_number, track2Data, track3Data, field55, pass_word);
        excuteRequest(msg, "zhccy");
    }

    /**
     * 智慧存签约
     */
    public void excuteZHCQY(String transn) {
        String c_bin_info = SpUtils.getSPUtil(getApplicationContext()).getString("c_bin_info", "null");
        Gson gson = new Gson();
        List<CardBinInfo_bean> beans = gson.fromJson(c_bin_info, new TypeToken<List<CardBinInfo_bean>>() {
        }.getType());
        Logger.e(beans.size() + "beans.size()");
        IsoMessage msg = null;
        ZHCQInterface inter = new ZHCQInterface();
        msg = inter.packRequest(transn, bindNum, "1", CardType, s_number, track2Data, track3Data, field55, pass_word, make_type);
        excuteRequest(msg, "zhcqy");
    }


    private void excuteRequest(IsoMessage msg, final String op_type) {

        byte[] data = msg.writeData();
        // ��д����ͷ��7�򳤶�ֵ
        int hlen = Constants.ATMP_HEADER_LENGTH;
        int bodylen = data.length - hlen;
        String headF7 = ServiceCommon.appendZero(bodylen, 4);
        System.arraycopy(headF7.getBytes(), 0, data, 28, 4);
        // ����MAC
        if (msg.getField(128) != null) {
//            int start = hlen;
//            int length = data.length - start - 8;
//            byte[] inmac = new byte[length];
//            byte[] outmac = new byte[16];
//            System.arraycopy(data, start, inmac, 0, length);
//
//            Logger.e(Constants.YANTAI_MACKEY);
//            String mackey = Constants.YANTAI_MACKEY;
//            // MAC99�㷨makֻ��Ҫ16�ֽ���Կ
//            if (mackey.length() > 16) {
//                mackey = mackey.substring(0, 16);
//            }
//            DES3.getMacBlock_99(inmac, mackey.getBytes(), outmac);
//            System.arraycopy(outmac, 0, data, data.length - 8, 8);
            int start = hlen;
            int length = data.length - start - 8 ;
            byte[] inmac = new byte[length];
            byte[] outmac = new byte[16];
            System.arraycopy(data, start, inmac, 0, length);
            System.out.println("MAC数据=["+ HexT.byteArr2HexStr(inmac)+"]");
            String mackey = Constants.YANTAI_MACKEY;

            if(Constants.isSM){
                // SM4 MAC919算法
                byte[] mkey = HexT.hexstr2ByteArr(mackey);
                String macval = SMS4.sms4MacBlock_919(inmac, mkey);
                outmac = macval.getBytes();
            }else{
                // MAC99算法mak只需要16字节密钥
                if(mackey.length()>16){
                    mackey = mackey.substring(0, 16);
                }
                DES3.getMacBlock_99(inmac, mackey.getBytes(), outmac);
            }

            System.arraycopy(outmac, 0, data, data.length-8, 8);
            System.out.println("请求MAC=["+new String(outmac).substring(0, 8)+"]");
        }
        byte[] send = null;
        // ���ļ��ܣ���������ʱ��ҵ���ױ��뱨�ļ���
        String encflag = msg.getHeadStringValue(4);
        if ("1".equals(encflag)) {
            String tdk = Constants.YANTAI_TDKKEY;
            int lenr = 8 - bodylen % 8;
            byte[] head = new byte[hlen];
            byte[] decdata = new byte[bodylen + lenr];
            System.arraycopy(data, 0, head, 0, hlen);
            System.arraycopy(data, hlen, decdata, 0, bodylen);
            byte[] encdata = DES3.des3Packet(decdata, tdk.getBytes());
            send = new byte[hlen + encdata.length];
            System.arraycopy(head, 0, send, 0, hlen);
            System.arraycopy(encdata, 0, send, hlen, encdata.length);

        }else if ("3".equals(encflag)){
            String tdk = Constants.YANTAI_TDKKEY;
            byte[] tdkey = HexT.hexstr2ByteArr(tdk);
            byte[] h7 = new byte[4];
            System.arraycopy(data, 28, h7, 0, 4);
            int orilen = Integer.parseInt(new String(h7));
            int enclen = data.length-Constants.ATMP_HEADER_LENGTH;
            byte[] head = new byte[Constants.ATMP_HEADER_LENGTH];
            byte[] encdata = new byte[enclen];
            System.arraycopy(data, 0, head, 0, Constants.ATMP_HEADER_LENGTH);
            System.arraycopy(data, Constants.ATMP_HEADER_LENGTH, encdata, 0, enclen);
            byte[] decdata = SMS4.unsms4Packet(encdata, tdkey);

            send = new byte[Constants.ATMP_HEADER_LENGTH+orilen];
            System.arraycopy(head, 0, send, 0, Constants.ATMP_HEADER_LENGTH);
            System.arraycopy(decdata, 0, send, Constants.ATMP_HEADER_LENGTH, orilen);
        } else {
            send = data;
        }

        CommAdapter adapter = new CommAdapter(Constants.IP, 3551);
        adapter.setHeadlen(4); // ����ͷ��4�ֽ�
        byte[] recv = adapter.doComm(send);

        byte[] recv2 = null;
        byte[] b = new byte[1];
        System.arraycopy(recv, 11, b, 0, 1);
        String rspenc = new String(b);

        if ("1".equals(rspenc)) {
            String tdk = Constants.YANTAI_TDKKEY;
            byte[] h7 = new byte[4];
            System.arraycopy(recv, 28, h7, 0, 4);
            int orilen = Integer.parseInt(new String(h7));
            int enclen = recv.length - Constants.ATMP_HEADER_LENGTH;
            byte[] head = new byte[Constants.ATMP_HEADER_LENGTH];
            byte[] encdata = new byte[enclen];
            System.arraycopy(recv, 0, head, 0, Constants.ATMP_HEADER_LENGTH);
            System.arraycopy(recv, Constants.ATMP_HEADER_LENGTH, encdata, 0, enclen);
            byte[] decdata = DES3.undes3Packet(encdata, tdk.getBytes());

            recv2 = new byte[Constants.ATMP_HEADER_LENGTH + orilen];
            System.arraycopy(head, 0, recv2, 0, Constants.ATMP_HEADER_LENGTH);
            System.arraycopy(decdata, 0, recv2, Constants.ATMP_HEADER_LENGTH, orilen);
        } else {
            recv2 = recv;
        }

        IsoMessage rsp = null;
        MessageFactory<IsoMessage> fac = new MessageFactory<IsoMessage>();
        try {
            rsp = fac.parseMessage(recv2, 32);
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        String respcode = rsp.getStringValue(39);
        if ("00".equals(respcode)) {


            unpackReSpone(rsp, op_type);
//            inter.unpackReSpone(rsp);
        } else if ("96".equals(respcode)) {
            Gson gson = new Gson();
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");// HH:mm:ss
            //获取当前时间
            Date date = new Date(System.currentTimeMillis());
            if (make_type.equals("zhcqy")) {
                StatisticalData_bean bean = new StatisticalData_bean(rwNUm, "", time, "智慧存签约", bindNum, username, SpUtils.getSPUtil(getApplicationContext()).getString("make_user", ""), pz_nums);
                String STAT_DATA = SpUtils.getSPUtil(getApplicationContext()).getString(simpleDateFormat.format(date).replace("/", ""), "");

                List<StatisticalData_bean> beans = gson.fromJson(STAT_DATA, new TypeToken<List<StatisticalData_bean>>() {
                }.getType());
                beans.add(bean);
                SpUtils.getSPUtil(getApplicationContext()).putString(simpleDateFormat.format(date).replace("/", "") + "UN_DATA", gson.toJson(beans));

            } else if (make_type.equals("zhcjy")) {
                StatisticalData_bean bean = new StatisticalData_bean(rwNUm, "", time, "智慧存解约", bindNum, username, SpUtils.getSPUtil(getApplicationContext()).getString("make_user", ""), pz_nums);
                String STAT_DATA = SpUtils.getSPUtil(getApplicationContext()).getString(simpleDateFormat.format(date).replace("/", ""), "");

                List<StatisticalData_bean> beans = gson.fromJson(STAT_DATA, new TypeToken<List<StatisticalData_bean>>() {
                }.getType());
                beans.add(bean);
                SpUtils.getSPUtil(getApplicationContext()).putString(simpleDateFormat.format(date).replace("/", "") + "UN_DATA", gson.toJson(beans));

            }

        } else {

            Logger.e("����ʧ��:[{}]-[{}]" + respcode + rsp.getStringValue(40));
            final IsoMessage finalRsp = rsp;
            Wisdomtosave_Activity.this.runOnUiThread(new Runnable() {
                @SuppressLint("WrongConstant")
                @Override
                public void run() {
                    Toast.makeText(getApplicationContext(), finalRsp.getStringValue(40), 5000).show();

                }
            });

            this.finish();
        }
    }

    private void unpackReSpone(IsoMessage response, String op_type) {

        rwNUm = response.getStringValue(37);
        final String f123 = response.getStringValue(123);
        if (op_type.equals("zhrz")) {
            String f123s[] = response.getStringValue(123).split("\\|");
            username = f123s[2];
            if (make_type.equals("zhcjy")) {
                //智慧存解约
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        ficationingLayout.setVisibility(View.GONE);
                        dealingLayout.setVisibility(View.VISIBLE);
                    }
                });
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
                        Logger.e("第一次获取" + num);
                        excuteZHCJY(String.valueOf(num));
                        SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
                        Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));
                    }
                }).start();
            } else if (make_type.equals("zhccy")) {
                //智慧存查阅
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        ficationingLayout.setVisibility(View.GONE);
                        dealingLayout.setVisibility(View.VISIBLE);
                    }
                });
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
                        Logger.e("第一次获取" + num);
                        excuteZHCCY(String.valueOf(num));
                        SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
                        Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));
                    }
                }).start();
            } else if (make_type.equals("wly") || make_type.equals("cxy")) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        ficationingLayout.setVisibility(View.GONE);
                        dealingLayout.setVisibility(View.VISIBLE);
                    }
                });
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");// HH:mm:ss
                //获取当前时间
                Date date = new Date(System.currentTimeMillis());
                time = simpleDateFormat.format(date);
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
                        Logger.e("第一次获取" + num);
                        excuteZHCQY(String.valueOf(num));
                        SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
                        Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));
                    }
                }).start();
            }

        } else if (op_type.equals("zhcjy")) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");// HH:mm:ss
            //获取当前时间
            Date date = new Date(System.currentTimeMillis());
            time = simpleDateFormat.format(date);
//            String f="6228860006000061            011200000000000000000000000001000000010000001000";
            PzGetUtils pzGetUtils = new PzGetUtils();
            pz_nums = pzGetUtils.pzutil(getApplication());

            final String num = f123.substring(0, 27).replaceAll(" ", "");
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    dealingLayout.setVisibility(View.GONE);
                    unbindAppointLayout.setVisibility(View.VISIBLE);
                    unbindAppointNum.setText(num);
                    if (f123.substring(31, 46).equals("000000000000000")) {
                        unbindAppointInterest.setText("0");
                    } else {
                        String lx_s = "";
                        String lx_end = "";
                        final String lx = f123.substring(31, 46).replaceAll("^(0+)", "");
                        if (lx.length() < 6) {
                            lx_s = "0";
                            lx_end = lx.substring(lx.length());
                            unbindAppointInterest.setText("0." + lx_end + "%");
                        } else {
                            Logger.e(lx);
                            lx_s = lx.substring(0, 1);
                            lx_end = lx.substring(1, lx.length());

                            unbindAppointInterest.setText(lx_s + "." + lx_end + "%");

                        }


                    }
                    if (f123.substring(f123.length() - 15).equals("000000000000000")) {
                        unbindAppointMoney.setText("0");
                    } else {
                        final String ye = f123.substring(f123.length() - 15).replaceAll("^(0+)", "");
                        String ye_s = ye.substring(0, ye.length() - 2);
                        String ye_end = ye.substring(ye.length() - 2);
                        unbindAppointMoney.setText(ye_s + "." + ye_end);
                    }
                    String lxs = "";
                    if (f123.substring(46, 61).equals("000000000000000")) {
                        unbindAppointInteresttax.setText("0");
                    } else {
                        lxs = f123.substring(46, 61).replaceAll("^(0+)", "");
                        final String lxs_start = lxs.substring(0, lxs.length() - 2);
                        final String lxs_end = lxs.substring(lxs.length() - 2);
                        unbindAppointInteresttax.setText(lxs_start + "." + lxs_end);
                    }
                }
            });
            Gson gson = new Gson();
            simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");// HH:mm:ss
            //获取当前时间
            date = new Date(System.currentTimeMillis());
            Logger.e("Date获取当前日期时间" + simpleDateFormat.format(date).replace("/", ""));
            StatisticalData_bean bean = new StatisticalData_bean(rwNUm, "0", time, "智慧存解约", bindNum, username, SpUtils.getSPUtil(getApplicationContext()).getString("make_user", ""), String.valueOf(pz_nums));
            String STAT_DATA = SpUtils.getSPUtil(getApplicationContext()).getString(simpleDateFormat.format(date).replace("/", ""), "");

            List<StatisticalData_bean> beans = gson.fromJson(STAT_DATA, new TypeToken<List<StatisticalData_bean>>() {
            }.getType());
            beans.add(bean);

            SpUtils.getSPUtil(getApplicationContext()).putString(simpleDateFormat.format(date).replace("/", ""), gson.toJson(beans));


//汇总查询
            String STAT_DATAALL = SpUtils.getSPUtil(getApplicationContext()).getString(simpleDateFormat.format(date).replace("/", "") + "ALL_DATA", "");
            List<Summary_Bean> beanalls = gson.fromJson(STAT_DATAALL, new TypeToken<List<Summary_Bean>>() {
            }.getType());
            if (!beanalls.get(0).getZhcjy().equals("")) {
                double money;
                String data[] = beanalls.get(0).getZhcjy().split(",");


                Logger.e(Double.parseDouble(data[0]) + "bbbbbbbbbbbbbb");
                int nums = Integer.valueOf(data[1]) + 1;
                String getZhcjy = "0" + "," + nums;
                Summary_Bean summary_bean = new Summary_Bean(beanalls.get(0).getZnqk(), beanalls.get(0).getXjhk(), beanalls.get(0).getZzhk(), beanalls.get(0).getYdhf(), beanalls.get(0).getLthf(), beanalls.get(0).getSgcc(), beanalls.get(0).getDzh(), beanalls.get(0).getHzd(), beanalls.get(0).getZhgm(), beanalls.get(0).getLwhc(), beanalls.get(0).getKtgs(), "", "", beanalls.get(0).getZhcqy(), getZhcjy, beanalls.get(0).getHnyqy(), beanalls.get(0).getHnyjy());
                beanalls.clear();
                beanalls.add(summary_bean);
                Logger.e(simpleDateFormat.format(date).replace("/", "") + "ALL_DATA");
                SpUtils.getSPUtil(getApplicationContext()).putString(simpleDateFormat.format(date).replace("/", "") + "ALL_DATA", gson.toJson(beanalls));

            } else {
                int nums = 1;

                String getZhcjy = "0" + "," + nums;
                Summary_Bean summary_bean = new Summary_Bean(beanalls.get(0).getZnqk(), beanalls.get(0).getXjhk(), beanalls.get(0).getZzhk(), beanalls.get(0).getYdhf(), beanalls.get(0).getLthf(), beanalls.get(0).getSgcc(), beanalls.get(0).getDzh(), beanalls.get(0).getHzd(), beanalls.get(0).getZhgm(), beanalls.get(0).getLwhc(), beanalls.get(0).getKtgs(), "", "", beanalls.get(0).getZhcqy(), getZhcjy, beanalls.get(0).getHnyqy(), beanalls.get(0).getHnyjy());
                beanalls.clear();
                beanalls.add(summary_bean);
                Logger.e(simpleDateFormat.format(date).replace("/", "") + "ALL_DATA");
                SpUtils.getSPUtil(getApplicationContext()).putString(simpleDateFormat.format(date).replace("/", "") + "ALL_DATA", gson.toJson(beanalls));

            }


        } else if (op_type.equals("zhccy")) {
            final String num = f123.substring(f123.length() - 28).replaceAll(" ", "");
            final String time = f123.substring(0, 8);
            final String yexx_s;
            final String yexx_end;
            //余额下限
            String yexx = f123.substring(8, 23).replaceAll("^(0+)", "");
            Logger.e(yexx);
            if (yexx == "") {
                yexx_s = "0";
                yexx_end = "0";
            } else {
                yexx_s = yexx.substring(0, yexx.length() - 2);
                yexx_end = yexx.substring(yexx.length() - 2);
            }

            //转存基数
            String zcjs = f123.substring(23, 38).replaceAll("^(0+)", "");
            final String zcjs_s = zcjs.substring(0, zcjs.length() - 2);
            final String zcjs_end = zcjs.substring(zcjs.length() - 2);
            //理财产品
            final String lccp = f123.substring(38, 63).replaceAll(" ", "");

            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    contractInformationLayout.setVisibility(View.VISIBLE);
                    wisdomtosaveCardview.setVisibility(View.GONE);
                    topupSuccessNum.setText(num);
                    contractInformationTime.setText(time);
                    contractInformationFloor.setText(yexx_s + "." + yexx_end);
                    contractInformationBasenum.setText(zcjs_s + "." + zcjs_end);
                    if (lccp.equals("888FSC816050100001")) {
                        contractInformationName.setText("稳利赢");
                    } else {
                        contractInformationName.setText("超享赢");
                    }

                }
            });
        } else if (op_type.equals("zhcqy")) {
            PzGetUtils pzGetUtils = new PzGetUtils();
            pz_nums = pzGetUtils.pzutil(getApplication());

            final String times = f123.substring(0, 8);
            Logger.e(times);
            String hqyexx = f123.substring(8, 23).replaceAll("^(0+)", "");
            final String hqyexx_s = hqyexx.substring(0, hqyexx.length() - 2);
            final String hqyexx_end = hqyexx.substring(hqyexx.length() - 2);
            hqyexxs = hqyexx_s + "." + hqyexx_end;
            final String zdzcjs = f123.substring(23, 38).replaceAll("^(0+)", "");
            final String zdzcjs_s = zdzcjs.substring(0, zdzcjs.length() - 2);
            final String zdzcjs_end = zdzcjs.substring(zdzcjs.length() - 2);
            zdzcjss = zdzcjs_s + "." + zdzcjs_end;

            final String yedata = f123.substring(f123.length() - 15).replaceAll("^(0+)", "");
            final String ye_s = yedata.substring(0, yedata.length() - 2);
            final String ye_end = yedata.substring(yedata.length() - 2);
            Logger.e(hqyexx);
            Logger.e(zdzcjs);
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    dealingLayout.setVisibility(View.GONE);
                    wisdomtosaveCardview.setVisibility(View.GONE);
                    signacontractSuccessLayout.setVisibility(View.VISIBLE);

                    signacontractSuccessTime.setText(times);
                    signacontractSuccessMoney.setText(bindNum);
                    signacontractSuccessCardinal.setText(zdzcjs_s + "." + zdzcjs_end);

                    if (make_type.equals("wly")) {
                        signacontractSuccessBalance.setText(ye_s + "." + ye_end);
                        signacontractSuccessName.setText("稳利赢");
                        signacontractSuccessBalancefloor.setText(hqyexx_s + "." + hqyexx_end);
                    } else {
                        signacontractSuccessBalance.setText("0.00");
                        signacontractSuccessName.setText("超享赢");
                        signacontractSuccessBalancefloor.setText("0.00");
                    }
                }
            });
            Gson gson = new Gson();
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");// HH:mm:ss
            //获取当前时间
            Date date = new Date(System.currentTimeMillis());
            Logger.e("Date获取当前日期时间" + simpleDateFormat.format(date).replace("/", ""));
            StatisticalData_bean bean = new StatisticalData_bean(rwNUm, "0", time, "智慧存签约", bindNum, username, SpUtils.getSPUtil(getApplicationContext()).getString("make_user", ""), String.valueOf(pz_nums));
            String STAT_DATA = SpUtils.getSPUtil(getApplicationContext()).getString(simpleDateFormat.format(date).replace("/", ""), "");

            List<StatisticalData_bean> beans = gson.fromJson(STAT_DATA, new TypeToken<List<StatisticalData_bean>>() {
            }.getType());
            beans.add(bean);

            SpUtils.getSPUtil(getApplicationContext()).putString(simpleDateFormat.format(date).replace("/", ""), gson.toJson(beans));


//汇总查询
            String STAT_DATAALL = SpUtils.getSPUtil(getApplicationContext()).getString(simpleDateFormat.format(date).replace("/", "") + "ALL_DATA", "");
            List<Summary_Bean> beanalls = gson.fromJson(STAT_DATAALL, new TypeToken<List<Summary_Bean>>() {
            }.getType());
            if (!beanalls.get(0).getZhcqy().equals("")) {
                double money;
                String data[] = beanalls.get(0).getZhcqy().split(",");


                Logger.e(Double.parseDouble(data[0]) + "bbbbbbbbbbbbbb");
                int num = Integer.valueOf(data[1]) + 1;
                String getZhcqy = "0" + "," + num;
                Summary_Bean summary_bean = new Summary_Bean(beanalls.get(0).getZnqk(), beanalls.get(0).getXjhk(), beanalls.get(0).getZzhk(), beanalls.get(0).getYdhf(), beanalls.get(0).getLthf(), beanalls.get(0).getSgcc(), beanalls.get(0).getDzh(), beanalls.get(0).getHzd(), beanalls.get(0).getZhgm(), beanalls.get(0).getLwhc(), beanalls.get(0).getKtgs(), "", "", getZhcqy, beanalls.get(0).getZhcjy(), beanalls.get(0).getHnyqy(), beanalls.get(0).getHnyjy());
                beanalls.clear();
                beanalls.add(summary_bean);
                Logger.e(simpleDateFormat.format(date).replace("/", "") + "ALL_DATA");
                SpUtils.getSPUtil(getApplicationContext()).putString(simpleDateFormat.format(date).replace("/", "") + "ALL_DATA", gson.toJson(beanalls));

            } else {
                int num = 1;

                String getZhcqy = "0" + "," + num;
                Summary_Bean summary_bean = new Summary_Bean(beanalls.get(0).getZnqk(), beanalls.get(0).getXjhk(), beanalls.get(0).getZzhk(), beanalls.get(0).getYdhf(), beanalls.get(0).getLthf(), beanalls.get(0).getSgcc(), beanalls.get(0).getDzh(), beanalls.get(0).getHzd(), beanalls.get(0).getZhgm(), beanalls.get(0).getLwhc(), beanalls.get(0).getKtgs(), "", "", getZhcqy, beanalls.get(0).getZhcjy(), beanalls.get(0).getHnyqy(), beanalls.get(0).getHnyjy());
                beanalls.clear();
                beanalls.add(summary_bean);
                Logger.e(simpleDateFormat.format(date).replace("/", "") + "ALL_DATA");
                SpUtils.getSPUtil(getApplicationContext()).putString(simpleDateFormat.format(date).replace("/", "") + "ALL_DATA", gson.toJson(beanalls));

            }

        }
    }


}
